efform_onload = function ()
{
};  

button_query_onclick = function (){
	efgrid.submitInqu( "ef_grid_result", "ZM","ZMCH30","query");
}

button_update_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")!="草拟")
		{
			EFAlert("只能对草拟的记录进行修改！"); return;
		}
	}
	efgrid.submitForm( "ef_grid_result", "ZM","ZMCH30","update",true);
}

button_insert_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return;	
	efgrid.submitForm( "ef_grid_result", "ZM","ZMCH30","insert",true);
}

button_delete_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")!="草拟")
		{
			EFAlert("只能对草拟的记录进行删除！"); return;
		}
	}
	EFConfirm('你确认要删除吗?', '确认框', function(r) {
		if(r)efgrid.submitForm( "ef_grid_result", "ZM","ZMCH30","delete",true);
	}); 
}

button_report_onclick = function (){
	if (isSelected("ef_grid_result") == 0)return; 
	EFConfirm('确认要上报吗?', '确认框', function(r) {
		if(r)efgrid.submitForm( "ef_grid_result", "ZM","ZMCH30","report",true);
	});
}

efgrid_afterAddNewRow = function(grid_id) {
	var grid = efgrid.getGridObject(grid_id);
	var rows = grid.getCheckedRows();
	if (grid_id == "ef_grid_result") {
		for (var i = 0; i < rows.length; i++) {
			grid.getBlockData().setCell(rows[i], "fdKeyId", "");
			grid.getBlockData().setCell(rows[i], "fdStatus", "草拟");
		}
	}
};

button_print_onclick = function() {
		var grid = efgrid.getGridObject("ef_grid_result");
		var row_index=grid.getCurrentRowIndex();
		if(row_index<0){
			EFAlert("请先点击一下选中项目信息后打印！");
			return;
		}
		var fdBeginTime=grid.getCellValueByColumnName(row_index,"fdBeginTime");
		var fdEndTime=grid.getCellValueByColumnName(row_index,"fdEndTime");
		// 取报表参数
		var param = [];
		param.StartDate =fdBeginTime.substr(0,10);
		param.EndDate =fdEndTime.substr(0,10);
		
		var reportEname = "ZDTM";
		try {
			previewReport(reportEname,param);
		} catch (e) {
			alert("控件加载失败，请确认控件是否正确安装并将本网站设为信任地址");
		}
};

